/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.tln.sys.user.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tln.sys.user.service.UserService;

/**
 * Web controller used when loading the home page.
 */
@Controller
public class HomeController {

	private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
	
	
	//private UserManager userManager;
	
    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }
    
   /* @Autowired
    public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}*/



	@RequestMapping("/home")
    public String viewHome(Model model) {
    	logger.info("viewHome111...........");
    	logger.info("userService... "+userService);
        model.addAttribute( "users", userService.getAllUsers() );
    	//List list = new ArrayList();//userManager.getAllUsers();
    	//logger.info("list size=== "+list.size());
    	//model.addAttribute( "users", list );
        logger.info("开始调整");
        return "/home";
    }
    
    @RequestMapping("/toHome")
    public String toHome(ModelMap modelMap) {
    	logger.info("toHome..222.........");
    	modelMap.addAttribute( "users", userService.getAllUsers() );
    	logger.info("**********************************");
        return "/home";
    }

}
